# Contributor: Bart Ribbers <bribbers@disroot.org>
# Contributor: knuxify <knuxify@gmail.com>
# Maintainer: Sertonix <sertonix@posteo.net>
pkgname=prismlauncher
pkgver=8.3
pkgrel=0
pkgdesc="A custom launcher for Minecraft that allows you to easily manage multiple installations of Minecraft at once"
url="https://prismlauncher.org/"
# blocked on riscv64 by openjdk
arch="all !riscv64"
license="GPL-3.0-only AND Apache-2.0"
depends="
	java-jre
	qt6-qtimageformats
	qt6-qtsvg
	"
makedepends="
	cmake
	extra-cmake-modules
	qt6-qtbase-dev
	qt6-qt5compat-dev
	qt6-qtimageformats-dev
	scdoc
	openjdk8
	quazip-dev
	samurai
	"
case "$CARCH" in
armv7|armhf) makedepends="$makedepends clang" ;; # fails to build with gcc, see note in build()
esac
install="$pkgname.post-install"
source="https://github.com/PrismLauncher/PrismLauncher/releases/download/$pkgver/PrismLauncher-$pkgver.tar.gz"
subpackages="$pkgname-doc"
builddir="$srcdir/PrismLauncher-$pkgver"

prepare() {
	default_prepare

	rm -rf libraries/quazip
}

build() {
	case "$CARCH" in
	armv7|armhf)
		# building with gcc fails, see https://github.com/PrismLauncher/PrismLauncher/issues/128
		export CC=clang
		export CXX=clang++
		;;
	esac

	JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk \
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DLauncher_QT_VERSION_MAJOR=6 \
		-DLauncher_BUILD_PLATFORM=alpinelinux
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
c4153fbfd5b6c09ecf2d78d95a629e78685a45a85ccbb5d7f8e4ec7bf7efb66d72f5eee0947ccb13090b4a8429b00cb92fdf96bb0dbe435b61a285d7517d37b2  PrismLauncher-8.3.tar.gz
"
